<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>添加进场单</title>
    <link rel="stylesheet" href="../layui/css/layui.css" />
    <link rel="stylesheet" href="../css/element.min.css?1" />
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_2315128_5bb2ydgeqs.css">
    <link rel="stylesheet" href="../css/reset.css?3133">
    <link rel="stylesheet" href="../css/setlayui.css?12">
    <link rel="stylesheet" href="../css/viewer.min.css">
    <script src="../layui/layui.all.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/vue.min.js"></script>
    <script type="text/javascript" src="../js/element.min.js"></script>
    <script src="../js/viewer.min.js"></script>
</head>

<body>
    <div id="app" class="page-container" style="display: none;" v-show="showApp">
        <div class="contetn_box">
            <div class="top_box">
                <div class="cell_box" style="width: 43.84vw;">
                    <div class="cell_title">
                        <div class="cell_name">基本信息:</div>
                        <div class="cell_but"></div>
                    </div>
                    <div class="cell_cont" style="height: 378px;">
                        <div class="form_box" style="margin-top: 0;">
                            <div class="form_name">进场单号</div>
                            <div class="form_cont">{{recordNumber}}</div>
                        </div>
                        <div class="form_box">
                            <div class="form_name must_input">供应商</div>
                            <div class="form_cont" style="padding-right: 10px;">
                                <el-tooltip class="item" effect="dark" :disabled="!supplier.supplierName"
                                    :content="supplier.supplierName" placement="top">
                                    <el-input disabled class="public_input" placeholder="请选择供应商"
                                        v-model="supplier.supplierName"></el-input>
                                </el-tooltip>
                            </div>
                            <div class="form_but" style="width: 62px;">
                                <!-- <el-button v-if="radio != 2 || !contract.contractId || (contract.contractId && (!supplier.supplierId || supplier.supplierId < 0))" @click="chioceGys" class="border_but" type="primary">选择</el-button> -->
                            </div>
                        </div>
                        <div class="form_box">
                            <div class="form_name">备注</div>
                            <div class="form_cont" style="padding-right: 10px;">
                                <el-tooltip class="item" effect="dark" :disabled="!remarks" :content="remarks"
                                    placement="top">
                                    <el-input type="textarea" :rows="3" placeholder="请输入" v-model="remarks"></el-input>
                                </el-tooltip>
                            </div>
                            <div class="form_but" style="width: 62px;">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="cell_box" style="width: 46.94vw;float: right;">
                    <div class="cell_title">
                        <div class="cell_name">现场抓拍:</div>
                        <div class="cell_but">
                            <el-button @click="chioceGlimg" class="border_but" type="primary">关联</el-button>
                        </div>
                    </div>
                    <div class="cell_cont" style="height: 378px; padding: 0 1.67vw;">
                        <div class="file_item">
                            <el-upload action="##" accept="image/*" list-type="picture-card" :show-file-list="false"
                                :http-request="zphttprequest" multiple>
                                <i class="el-icon-plus"></i>
                            </el-upload>
                        </div>
                        <div class="file_item" v-for="(item, index) in glimgList" :key="index"
                            style="border: 2px solid #999999;">
                            <img :src="item.fileurl" alt="">
                            <div class="file_mask">
                                <div @click="prevewImg(item.fileurl)" class="el-icon-zoom-in"></div>
                                <div @click="downImg(item.filename, item.fileurl)" class="el-icon-download"
                                    style="margin: 0 20px;"></div>
                                <div @click="removeImg(glimgList, index)" class="el-icon-delete"></div>
                            </div>
                        </div>
                        <div class="file_item" v-for="(item, index) in listGlchioceImgData" :key="index"
                            style="border: 2px solid #999999;">
                            <img :src="item.fileurl" alt="">
                            <div class="file_mask">
                                <div @click="prevewImg(item.fileurl)" class="el-icon-zoom-in"></div>
                                <div @click="downImg(item.filename, item.fileurl)" class="el-icon-download"
                                    style="margin: 0 20px;"></div>
                                <div @click="removeImg(listGlchioceImgData, index)" class="el-icon-delete"></div>
                            </div>
                        </div>
                        <div class="file_item" v-for="(item, index) in noorderImgData" :key="index"
                            style="border: 2px solid #999999;">
                            <img :src="item.fileurl" alt="">
                            <div class="file_mask">
                                <div @click="prevewImg(item.fileurl)" class="el-icon-zoom-in"></div>
                                <div @click="downImg(item.filename, item.fileurl)" class="el-icon-download"
                                    style="margin: 0 20px;"></div>
                                <div @click="removeImg(noorderImgData, index)" class="el-icon-delete"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="cell_box" style="padding-left: 3.34vw;margin-top: 30px;">
                <div class="cell_title">
                    <div class="cell_name">送货单照片:</div>
                    <div class="cell_but">
                        <!-- <el-upload
                                class="upload-demo"
                                action="##"
                                accept="image/*"
                                multiple
                                :show-file-list="false"
                                :http-request="shdhttprequest">
                                <el-button class="border_but" type="primary">上传照片</el-button> -->
                        <!-- </el-upload> -->
                    </div>
                </div>
                <div class="cell_cont" style="width: 544px;">
                    <div class="table_box border_table_box">
                        <el-table :data="fileList" max-height="400px" border style="width: 100%">

                            <el-table-column prop="filename" align="center" min-width="100" show-overflow-tooltip
                                label="名称"></el-table-column>

                            <el-table-column prop="userName" align="center" show-overflow-tooltip label="上传人"
                                min-width="70">
                            </el-table-column>

                            <el-table-column prop="uploadTime" align="center" show-overflow-tooltip label="上传时间"
                                width="160">
                            </el-table-column>

                            <el-table-column align="center" show-overflow-tooltip label="操作" width="140">
                                <template slot-scope="scope">
                                    <el-button @click="prevewImg(scope.row.fileurl)" type="text">查看</el-button>
                                    <el-button @click="downImg(scope.row.filename, scope.row.fileurl)" type="text">下载
                                    </el-button>
                                    <!-- <el-button @click="removeImg(fileList, scope.$index)" type="text">删除</el-button> -->
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
            </div>
            <div class="cell_box" style="width: 100%; padding:0 1.84vw 0 3.34vw;margin-top: 30px;">
                <div class="cell_title">
                    <div class="cell_name">订单明细:</div>
                    <div class="cell_but">
                        <el-button @click="chioceorder" class="border_but" type="primary">添加订单</el-button>
                    </div>
                </div>
                <div class="cell_cont">
                    <div v-for="(item, index) in allTableData" :key="index">
                        <div class="list_title" style="padding: 10px 0;display: flex;">
                            <div
                                style="display: flex;align-items: center;color:#fff;background: #fa7355;border-radius: 4px;padding: 4px 10px;">
                                <div>采购订单 {{item.orderNo}}</div>
                                <div v-if="item.isAdd" @click="removeImg(allTableData, index, 1)"
                                    class="el-icon-circle-close" style="margin-left: 20px;cursor: pointer;color:#fff;">
                                </div>
                            </div>
                        </div>
                        <div class="table_box border_table_box" style="margin-bottom: 10px;">
                            <el-table :data="item.clmxList" border style="width: 100%" height="400">

                                <el-table-column prop="materialName" align="center" min-width="100"
                                    show-overflow-tooltip label="名称"></el-table-column>
                                <el-table-column prop="specsName" align="center" show-overflow-tooltip label="规格"
                                    min-width="70">
                                </el-table-column>
                                <el-table-column align="center" show-overflow-tooltip label="生产厂家" min-width="140">
                                    <template slot-scope="scope">
                                        <div v-if="scope.row.isAdd">
                                            <div style="display: flex;align-items: center;justify-content: center;"
                                                v-if="!scope.row.manufacturerId || scope.row.manufacturerId.length == 0">
                                                <el-button @click="chioceCj(item, scope.row, scope.$index)"
                                                    class="border_but" style="height: 24px;margin-right: 0;"
                                                    type="primary">选择厂家</el-button>
                                            </div>
                                            <div @click="chioceCj(item, scope.row, scope.$index)"
                                                style="color: #5574D7;text-decoration: underline;cursor: pointer;"
                                                v-if="scope.row.manufacturerId && scope.row.manufacturerId.length > 0">
                                                {{scope.row.manufacturer}}</div>
                                        </div>
                                        <div v-if="!scope.row.isAdd">
                                            <div>{{scope.row.manufacturer}}</div>
                                        </div>
                                    </template>
                                </el-table-column>

                                <el-table-column align="center" show-overflow-tooltip label="进场车牌" min-width="140">
                                    <template slot-scope="scope">
                                        <div v-if="scope.row.isAdd">
                                            <div style="display: flex;align-items: center;justify-content: center;"
                                                v-if="!scope.row.uuidlicensePlates">
                                                <el-button @click="chioceCpss(index, scope.row, scope.$index)"
                                                    class="border_but" style="height: 24px;margin-right: 0;"
                                                    type="primary">关联车牌</el-button>
                                            </div>
                                            <div @click="chioceCpss(index, scope.row, scope.$index)"
                                                style="color: #5574D7;text-decoration: underline;cursor: pointer;"
                                                v-if="scope.row.uuidlicensePlates">{{scope.row.showCpValue}}</div>
                                        </div>
                                        <div v-if="!scope.row.isAdd">
                                            <div v-if="scope.row.uuidlicensePlates">{{scope.row.showCpValue}}</div>
                                        </div>
                                    </template>
                                </el-table-column>

                                <el-table-column align="center" show-overflow-tooltip label="进场数量" width="160">
                                    <template slot-scope="scope">
                                        <div class="table_input">
                                            <el-input placeholder="请输入内容" :disabled="!scope.row.isAdd" :min="0"
                                                type="number" v-model="scope.row.count" clearable></el-input>
                                        </div>
                                    </template>
                                </el-table-column>

                                <el-table-column prop="unit" align="center" show-overflow-tooltip label="单位"
                                    min-width="70">
                                </el-table-column>

                                <el-table-column prop="approachTime" align="center" show-overflow-tooltip label="进场时间"
                                    width="242">
                                    <template slot-scope="scope">
                                        <div class="table_input">
                                            <el-date-picker v-model="scope.row.approachTime" type="datetime"
                                                format="yyyy-MM-dd HH:mm" :disabled="!scope.row.isAdd"
                                                value-format="yyyy-MM-dd HH:mm" placeholder="选择日期时间">
                                            </el-date-picker>
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column align="center" show-overflow-tooltip label="存放位置" min-width="150">
                                    <template slot-scope="scope">
                                        <div v-if="scope.row.isAdd">
                                            <div style="display: flex;align-items: center;"
                                                v-if="!scope.row.storageId || scope.row.storageId.length == 0">
                                                <el-button @click="chioceCk(item, scope.row, scope.$index)"
                                                    class="border_but" style="height: 24px;margin-right: 0;"
                                                    type="primary">选择仓库</el-button>
                                            </div>
                                            <div @click="chioceCk(item, scope.row, scope.$index)"
                                                style="color: #5574D7;text-decoration: underline;cursor: pointer;"
                                                v-if="scope.row.storageId && scope.row.storageId.length > 0">
                                                {{scope.row.storageName}} <span
                                                    v-if="scope.row.goodsShelvesNumber">({{scope.row.goodsShelvesNumber}})</span>
                                            </div>
                                        </div>
                                        <div v-if="!scope.row.isAdd">
                                            <div v-if="scope.row.storageId && scope.row.storageId.length > 0">
                                                {{scope.row.storageName}} <span
                                                    v-if="scope.row.goodsShelvesNumber">({{scope.row.goodsShelvesNumber}})</span>
                                            </div>
                                        </div>
                                    </template>
                                </el-table-column>

                                <el-table-column align="center" show-overflow-tooltip label="操作" width="106">
                                    <template slot-scope="scope">
                                        <el-button v-if="scope.row.isAdd"
                                            @click="removeImg(item.clmxList, scope.$index, 1)" type="text">删除
                                        </el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- <div class="cell_box" style="width: 100%; padding:0 1.84vw 0 3.34vw;margin-top: 30px;">
                    <div class="cell_title">
                        <div class="cell_name">无订单进场明细:</div>
                        <div class="cell_but">
                            <el-button @click="chioceClmx" class="border_but" type="primary">添加材料</el-button>
                        </div>
                    </div>
                    <div class="cell_cont">
                        <div class="table_box border_table_box">
                            <el-table :data="clmxList" border style="width: 100%">
                                    
                                <el-table-column prop="materialName" align="center" min-width="100" show-overflow-tooltip label="名称"></el-table-column>
                                
                                <el-table-column prop="specsName" align="center" show-overflow-tooltip label="规格" min-width="70">
                                </el-table-column>
                                
                                <el-table-column align="center" show-overflow-tooltip label="进场车牌" min-width="140">
                                    <template slot-scope="scope">
                                        <div style="display: flex;align-items: center;justify-content: center;" v-if="!scope.row.uuidlicensePlates">
                                            <el-button @click="chiocenoorderCpss(scope.row, scope.$index)" class="border_but" style="height: 24px;margin-right: 0;" type="primary">关联车牌</el-button>
                                        </div>
                                        <div @click="chiocenoorderCpss(scope.row, scope.$index)" style="color: #5574D7;text-decoration: underline;cursor: pointer;" v-if="scope.row.uuidlicensePlates">{{scope.row.showCpValue}}</div>
                                    </template>
                                </el-table-column>

                                <el-table-column align="center" show-overflow-tooltip label="进场数量" width="160">
                                    <template slot-scope="scope">
                                        <div class="table_input" v-if="scope.row.isAdd">
                                            <el-input placeholder="请输入内容" type="number" :min="0" v-model="scope.row.count" clearable></el-input>
                                        </div>
                                        <span v-if="!scope.row.isAdd">{{scope.row.count}}</span>
                                    </template>
                                </el-table-column>
    
                                <el-table-column prop="unit" align="center" show-overflow-tooltip label="单位" min-width="70">
                                </el-table-column>
    
                                <el-table-column prop="approachTime" align="center" show-overflow-tooltip label="进场时间" min-width="242">
                                    <template slot-scope="scope">
                                        <div class="table_input">
                                            <el-date-picker
                                                v-model="scope.row.approachTime"
                                                type="datetime"
                                                format="yyyy-MM-dd HH:mm"
                                                value-format="yyyy-MM-dd HH:mm"
                                                placeholder="选择日期时间">
                                            </el-date-picker>
                                        </div>
                                    </template>
                                </el-table-column>

                                <el-table-column align="center" show-overflow-tooltip label="存放位置" min-width="150">
                                    <template slot-scope="scope">
                                        <el-button @click="chioceCk2(scope.row, scope.$index)" v-if="!scope.row.storageId" class="border_but" style="height: 24px;margin: 0 auto;" type="primary">选择仓库</el-button>
                                        <el-button @click="chioceCk2(scope.row, scope.$index)" v-if="scope.row.isAdd && scope.row.storageId" class="txt_link" type="text">{{scope.row.storageName}}<span v-if="scope.row.goodsShelvesNumber.length > 0">({{scope.row.goodsShelvesNumber}})</span></el-button>
                                        <span v-if="!scope.row.isAdd && scope.row.storageId">{{scope.row.storageName}}<span v-if="scope.row.goodsShelvesNumber.length > 0">({{scope.row.goodsShelvesNumber}})</span></span>
                                    </template>
                                </el-table-column>

                                <el-table-column align="center" show-overflow-tooltip label="操作" width="106">
                                    <template slot-scope="scope">
                                        <el-button @click="removeImg(clmxList, scope.$index, 1)" v-if="scope.row.isAdd" type="text">删除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>
                </div> -->
        </div>
        <div class="but_box">
            <el-button @click="cancels" class="cancelClass">取消</el-button>
            <el-button @click="confirms2" type="primary" style="margin-left: 120px">提交</el-button>
        </div>
        <el-dialog title="选择车牌" :visible.sync="dialogVisible" custom-class="public_popup" width="60%">
            <div class="public_popup_box">
                <div class="public_popup_cell_box">
                    <div class="popup_cell_name must_input">输入或选择车牌:</div>
                    <div class="popup_cell_item" v-for="(item, index) in inputcpList" :key="index">
                        <div style="display: flex;">
                            <div class="popup_cell_cont" style="padding-right: 10px;">
                                <el-tooltip class="item" effect="dark" :disabled="!item.licensePlate"
                                    :content="item.licensePlate" placement="top">
                                    <el-input placeholder="请输入内容" v-model="item.licensePlate" class="public_input"
                                        @change="bindCpImg(index)" clearable>
                                    </el-input>
                                </el-tooltip>

                            </div>
                            <div style="display: flex;align-items: center;width: 202px;">
                                <el-button @click="removeImg(inputcpList, index, 1)" v-if="index != 0"
                                    class="border_but" type="primary">删除</el-button>
                                <el-button @click="addCpId(item)" v-if="index == inputcpList.length - 1"
                                    class="border_but" type="primary">新增</el-button>
                                <el-button @click="xzCpimg" v-if="index == inputcpList.length - 1" class="border_but"
                                    type="primary">选择</el-button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="but_box">
                    <el-button @click="dialogVisible = false" class="cancelClass">取消</el-button>
                    <el-button v-if="popupType == 1" type="primary" @click="chioceCpConfirm" style="margin-left: 120px">
                        提交</el-button>
                    <el-button v-if="popupType == 2" type="primary" @click="chioceorderCpConfirm"
                        style="margin-left: 120px">提交</el-button>
                </div>
            </div>
        </el-dialog>
        <el-dialog title="无订单进场的材料需要选择一个合同或输入单价" :visible.sync="orderdialogVisible" custom-class="public_popup"
            width="80%">
            <div class="public_popup_box">
                <div class="public_popup_cell_box">
                    <div class="creat_order_box">
                        <div class="creat_order_name">关联合同</div>
                        <div class="creat_order_cont" style="margin-left: 20px;">
                            <el-tooltip class="item" effect="dark" :disabled="!noorderHtObj.noorderHtName"
                                :content="noorderHtObj.noorderHtName" placement="top">
                                <el-input placeholder="请输入内容" disabled v-model="noorderHtObj.noorderHtId"
                                    class="public_input" clearable>
                                </el-input>
                            </el-tooltip>

                        </div>
                        <div style="margin-left: 20px;">
                            <el-button @click="chioceht" class="border_but" type="primary">选择</el-button>
                        </div>
                    </div>
                    <div class="creat_order_table table_box border_table_box">
                        <el-table height="100%" :data="creatOrderList" border style="width: 100%">

                            <el-table-column prop="materialName" align="center" min-width="100" show-overflow-tooltip
                                label="名称"></el-table-column>

                            <el-table-column prop="specsName" align="center" show-overflow-tooltip label="规格"
                                min-width="70">
                            </el-table-column>

                            <el-table-column prop="count" align="center" show-overflow-tooltip label="进场数量" width="120">
                            </el-table-column>

                            <el-table-column prop="unit" align="center" show-overflow-tooltip label="单位" min-width="70">
                            </el-table-column>

                            <el-table-column prop="unit" align="center" show-overflow-tooltip label="单价"
                                min-width="160">
                                <template slot-scope="scope">
                                    <div class="table_input">
                                        <el-input @change="changeValue" @input="changeValues(scope.$index, scope.row)"
                                            :disabled="scope.row.isedit" placeholder="请输入内容" :min="0" type="number"
                                            v-model="scope.row.price" clearable></el-input>
                                    </div>
                                </template>
                            </el-table-column>

                            <el-table-column prop="taxRate" align="center" show-overflow-tooltip label="税率"
                                min-width="160">
                                <template slot-scope="scope">
                                    <div style="display: flex;align-items: center;justify-content: center;">
                                        <div class="table_input" style="width: 100px;">
                                            <el-input @change="changeValue"
                                                @input="changeValues(scope.$index, scope.row)"
                                                :disabled="scope.row.isedit" placeholder="请输入内容" :min="0" type="number"
                                                v-model="scope.row.taxRate" clearable></el-input>
                                        </div>
                                        <div>%</div>
                                    </div>
                                </template>
                            </el-table-column>

                        </el-table>
                    </div>
                </div>
                <div class="but_box">
                    <el-button @click="orderdialogVisible = false" class="cancelClass">取消</el-button>
                    <el-button type="primary" @click="creatOrderBut" style="margin-left: 120px">提交</el-button>
                </div>
            </div>
        </el-dialog>
        <ul id="jq22" style="opacity: 0;height: 0;overflow: hidden;">
            <li v-for="(item, index) in previewList" :key="index"><img :src="item" /></li>
        </ul>
    </div>
    <script src="../js/FileSaver.js"></script>
    <script src="../js/public.js?123456"></script>
    <script>
        var layer = layui.layer
        var vm = new Vue({
            el: '#app',
            data() {
                return {
                    noorderHtObj: {
                        noorderHtId: '',
                        noorderHtName: '',
                    },
                    recordNumber: '',
                    creatOrderList: [],
                    orderdialogVisible: false,
                    dialogVisible: false,
                    showApp: false,
                    projectId: '',
                    recordId: '',
                    allIndex: '',
                    childIndex: '',
                    inputcpList: [{
                        uuid: '',
                        licensePlate: '',
                        pictureId: '',
                        pictureURL: '',
                    }],
                    childorderIndex: '',
                    popupType: 1,
                    noorderImgData: [],
                    companyId: '',
                    radio: '1',
                    input: '',
                    inputtypeImg: [],
                    contract: {
                        contractId: '',
                        contractName: ''
                    },
                    plan: {
                        planId: '',
                        planName: ''
                    },
                    supplier: {
                        supplierId: '',
                        supplierName: ''
                    },
                    remarks: '',
                    allTableData: [],
                    clmxList: [],
                    fileList: [],
                    glimgList: [],
                    listGlchioceImgData: [],
                    listGlinputImgData: [],
                    previewList: [],
                    isRequestFlag: false,
                    isLoading: false,
                    isWddRequest: false
                };
            },
            methods: {
                creatOrderBut() {
                    if(this.isRequestFlag){
                        return
                    }
                    var that = this
                    for (var i = 0; i < this.creatOrderList.length; i++) {
                        if (!this.creatOrderList[i].price || this.creatOrderList[i].price == 0) {
                            this.$message({
                                message: '请输入单价',
                                type: 'warning',
                                duration: 1000
                            });
                            return false
                        }
                    }
                    var newArr = []
                    for (var i = 0; i < this.creatOrderList.length; i++) {
                        newArr.push({
                            oper: 'add',
                            manufacturerID: this.creatOrderList[i].manufacturerID,
                            quantity: this.creatOrderList[i].count,
                            price: this.creatOrderList[i].price,
                            taxRate: this.creatOrderList[i].taxRate,
                            arrivalTime: this.creatOrderList[i].approachTime,
                            materialName: this.creatOrderList[i].materialName,
                            materialId: this.creatOrderList[i].materialId,
                            specificationId: this.creatOrderList[i].specsId,
                            specificationName: this.creatOrderList[i].specsName,
                            unit: this.creatOrderList[i].unit,
                            storageId: this.creatOrderList[i].storageId,
                            goodsShelvesId: this.creatOrderList[i].goodsShelvesId,
                            goodsShelvesNumber: this.creatOrderList[i].goodsShelvesNumber
                        })
                    }
                    this.isRequestFlag = true;
                    xLoading(true, '正在创建订单')
                    $.ajax({
                        type: 'post',
                        url: baseUrl + '/Material/SavePurchaseOrderDatas',
                        data: {
                            contractId: that.noorderHtObj.noorderHtId,
                            contractName: that.noorderHtObj.noorderHtName,
                            jsonDatas: JSON.stringify(newArr)
                        },
                        dataType: 'json',
                        success: function (res) {
                            xLoading(false)
                            if (!res.success) {
                                that.$message({
                                    message: res.msg ? res.msg : '程序错误，请重试',
                                    type: 'error'
                                });
                                return false;
                            }
                            setTimeout(function () {
                                that.isRequestFlag = false;
                                that.confirms1(res.recid, res.orderNumber)
                            }, 100)
                        }
                    });
                },
                changeValues(index, row) {
                    this.$set(this.creatOrderList, index, row)
                },
                changeValue(value) {
                    this.$forceUpdate()
                },
                chioceorderCpConfirm() {
                    if (this.inputcpList.length === 1 && this.inputcpList[0].uuid === "" && this.inputcpList[0].licensePlate === "" && this.inputcpList[0].pictureURL === "") {
                        this.dialogVisible = false
                        return
                    }
                    var uuidlicensePlates = []
                    var showCpValue = []
                    var uuidImgs = []
                    for (var i = 0; i < this.inputcpList.length; i++) {
                        uuidlicensePlates.push((this.inputcpList[i].uuid ? this.inputcpList[i].uuid : 0) + ',' + this.inputcpList[i].licensePlate)
                        showCpValue.push(this.inputcpList[i].licensePlate)
                        if (this.inputcpList[i].pictureId && this.inputcpList[i].pictureId != 0) {
                            this.listGlchioceImgData.push({
                                fileid: this.inputcpList[i].pictureId,
                                filename: '抓拍图片' + this.inputcpList[i].pictureId + '.png',
                                fileurl: this.inputcpList[i].pictureURL,
                                types: 'glList'
                            })
                        }
                        uuidImgs.push((this.inputcpList[i].uuid ? this.inputcpList[i].uuid : 0) + ',' + this.inputcpList[i].licensePlate + ',' + (this.inputcpList[i].pictureId ? this.inputcpList[i].pictureId : 0) + ',' + (this.inputcpList[i].pictureId ? this.inputcpList[i].pictureURL : 0))
                    }
                    this.clmxList[this.childorderIndex].uuidlicensePlates = uuidlicensePlates.join('|')
                    this.clmxList[this.childorderIndex].showCpValue = showCpValue.join(',')
                    this.clmxList[this.childorderIndex].uuidImgs = uuidImgs.join('|')
                    this.$forceUpdate()
                    this.dialogVisible = false
                },
                chioceCpConfirm() {
                    if (this.inputcpList.length === 1 && this.inputcpList[0].uuid === "" && this.inputcpList[0].licensePlate === "" && this.inputcpList[0].pictureURL === "") {
                        this.dialogVisible = false
                        return
                    }
                    var uuidlicensePlates = []
                    var showCpValue = []
                    var uuidImgs = []
                    for (var i = 0; i < this.inputcpList.length; i++) {
                        uuidlicensePlates.push((this.inputcpList[i].uuid ? this.inputcpList[i].uuid : 0) + ',' + this.inputcpList[i].licensePlate)
                        showCpValue.push(this.inputcpList[i].licensePlate)
                        if (this.inputcpList[i].pictureId && this.inputcpList[i].pictureId != 0) {
                            this.listGlchioceImgData.push({
                                fileid: this.inputcpList[i].pictureId,
                                filename: '抓拍图片' + this.inputcpList[i].pictureId + '.png',
                                fileurl: this.inputcpList[i].pictureURL,
                                types: 'glList'
                            })
                        }
                        uuidImgs.push((this.inputcpList[i].uuid ? this.inputcpList[i].uuid : 0) + ',' + this.inputcpList[i].licensePlate + ',' + (this.inputcpList[i].pictureId ? this.inputcpList[i].pictureId : 0) + ',' + (this.inputcpList[i].pictureId ? this.inputcpList[i].pictureURL : 0))
                    }
                    this.allTableData[this.allIndex].clmxList[this.childIndex].uuidlicensePlates = uuidlicensePlates.join('|')
                    this.allTableData[this.allIndex].clmxList[this.childIndex].showCpValue = showCpValue.join(',')
                    this.allTableData[this.allIndex].clmxList[this.childIndex].uuidImgs = uuidImgs.join('|')
                    this.$forceUpdate()
                    this.dialogVisible = false
                },
                bindCpImg(item) {
                    this.inputcpList[item].uuid = ''
                    this.inputcpList[item].pictureId = ''
                    this.inputcpList[item].pictureURL = ''
                    var that = this
                    var timeData = []
                    this.$forceUpdate()
                    timeData = [timeFormat(new Date(new Date().getTime() - 1 * 60 * 60 * 1000), 1), timeFormat(new Date(), 1)]
                    if (!that.inputcpList[item].licensePlate) {
                        return false
                    }
                    xLoading(true)
                    $.ajax({
                        type: 'post',
                        headers: {
                        },
                        url: baseUrl + '/Material/GetCarInfo',
                        data: {
                            inputLicensePlate: that.inputcpList[item].licensePlate,
                            startTime: timeData[0],
                            endTime: timeData[1]
                        },
                        dataType: 'json',
                        success: function (res) {
                            xLoading(false)
                            if (!res.success) {
                                return false;
                            }
                            if (!res.data) {
                                return false
                            }
                            that.inputcpList[item].uuid = res.data[0].uuid
                            that.inputcpList[item].pictureId = res.data[0].pictureId
                            that.inputcpList[item].pictureURL = res.data[0].pictureURL
                        }
                    });
                },
                xzCpimg() {
                    var that = this
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择车牌',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['77.91%', '98.88%'],
                        // area: ['91.91%', '72.16%'],
                        content: '../publicList/jccpImgList.html?companyId=' + that.companyId + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    for (var i = 0; i < newList.length; i++) {
                                        that.inputcpList.push({
                                            uuid: newList[i].uuid,
                                            licensePlate: newList[i].licensePlate,
                                            pictureId: newList[i].pictureId,
                                            pictureURL: newList[i].pictureURL
                                        })
                                    }
                                    for (var i = 0; i < that.inputcpList.length; i++) {
                                        if (!that.inputcpList[i].licensePlate) {
                                            that.inputcpList.splice(i, 1)
                                        }
                                    }
                                }
                            }, 10)
                        }
                    });
                },
                addCpId(item) {
                    if (!item.licensePlate) {
                        return false
                    }
                    this.inputcpList.push({
                        uuid: '',
                        licensePlate: '',
                        pictureId: '',
                        pictureURL: ''
                    })
                },
                chiocenoorderCpss(row, index) {
                    var that = this
                    this.dialogVisible = true
                    this.childorderIndex = index
                    this.inputcpList = []
                    this.popupType = 2
                    if (row.uuidImgs) {
                        for (var i = 0; i < row.uuidImgs.split('|').length; i++) {
                            this.inputcpList.push({
                                uuid: row.uuidImgs.split('|')[i].split(',')[0],
                                licensePlate: row.uuidImgs.split('|')[i].split(',')[1],
                                pictureId: row.uuidImgs.split('|')[i].split(',')[2],
                                pictureURL: row.uuidImgs.split('|')[i].split(',')[3],
                            })
                        }
                    } else {
                        this.inputcpList.push({
                            uuid: '',
                            licensePlate: '',
                            pictureId: '',
                            pictureURL: '',
                        })
                    }
                },
                chioceCpss(item, row, index) {
                    var that = this
                    this.dialogVisible = true
                    this.allIndex = item
                    this.childIndex = index
                    this.popupType = 1
                    this.inputcpList = []
                    if (row.uuidImgs) {
                        for (var i = 0; i < row.uuidImgs.split('|').length; i++) {
                            this.inputcpList.push({
                                uuid: row.uuidImgs.split('|')[i].split(',')[0],
                                licensePlate: row.uuidImgs.split('|')[i].split(',')[1],
                                pictureId: row.uuidImgs.split('|')[i].split(',')[2],
                                pictureURL: row.uuidImgs.split('|')[i].split(',')[3],
                            })
                        }
                    } else {
                        this.inputcpList.push({
                            uuid: '',
                            licensePlate: '',
                            pictureId: '',
                            pictureURL: '',
                        })
                    }
                },
                chioceCj(item, row, index) {
                    var that = this
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择生产厂家',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['77.91%', '98.88%'],
                        // area: ['91.91%', '72.16%'],
                        content: '../publicList/gysList.html?isSingle=1&companyId=' + that.companyId + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    row.manufacturerId = newList[0].id
                                    row.manufacturer = newList[0].name
                                    item.clmxList[index] = row
                                    that.$forceUpdate()
                                }
                            }, 10)
                        }
                    });
                },
                // 选择位置
                chioceCk(item, row, index) {
                    var that = this
                    var selectArr = []
                    var materiaobj = {}
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择仓库货架',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['77.91%', '98.88%'],
                        // area: ['91.91%', '72.16%'],
                        content: '../publicList/ckList.html?isSingle=1&materiaobj=' + encodeURIComponent(JSON.stringify(materiaobj)) + '&projectId=' + that.projectId + '&selectArr=' + encodeURIComponent(JSON.stringify(selectArr)) + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    row.storageId = newList[0].id
                                    row.storageName = newList[0].name
                                    row.goodsShelvesNumber = newList[0].x_goodsShelvesNumber
                                    row.goodsShelvesId = newList[0].x_goodsShelvesId
                                    item.clmxList[index] = row
                                    that.$forceUpdate()
                                    // that.$set(that.clmxList, index, row)
                                }
                            }, 10)
                        }
                    });
                },
                // 选择位置
                chioceCk2(row, index) {
                    var that = this
                    var selectArr = []
                    for (var i = 0; i < this.clmxList.length; i++) {
                        selectArr.push({
                            id: this.clmxList[i].storageId,
                            number: this.clmxList[i].goodsShelvesNumber,
                        })
                    }
                    var materiaobj = {
                        materialId: row.materialId + '',
                        specsId: row.specificationId + ''
                    }
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择仓库货架',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['77.91%', '98.88%'],
                        // area: ['91.91%', '72.16%'],
                        content: '../publicList/ckList.html?isSingle=1&materiaobj=' + encodeURIComponent(JSON.stringify(materiaobj)) + '&projectId=' + that.projectId + '&selectArr=' + encodeURIComponent(JSON.stringify(selectArr)) + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    row.storageId = newList[0].id
                                    row.storageName = newList[0].name
                                    row.goodsShelvesNumber = newList[0].x_goodsShelvesNumber
                                    row.goodsShelvesId = newList[0].x_goodsShelvesId
                                    that.$set(that.clmxList, index, row)
                                }
                            }, 10)
                        }
                    });
                },
                cancels() {
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                },
                confirms2() {
                    if(this.isLoading){
                        return
                    }
                    var that = this
                    xLoading(true, '正在校验')
                    that.isLoading = true;
                    $.ajax({
                        type: 'post',
                        headers: {
                        },
                        url: baseUrl + '/Material/GetProjectInventoryStatus',
                        data: {
                            // planId: that.plan.planId
                        },
                        dataType: 'json',
                        success: function (res) {
                            xLoading(false)
                            if (!res.success) {
                                that.$message({
                                    message: res.msg ? res.msg : '程序错误，请重试',
                                    type: 'error'
                                });
                                that.isLoading = false;
                                return false;
                            }
                            if (res.data == 1) {
                                that.$message({
                                    message: '盘点中，不可添加进场单',
                                    type: 'error'
                                });
                                that.isLoading = false;
                                return false
                            }
                            if (that.clmxList.length > 0) {
                                // 无订单明细
                                that.isLoading = false;
                                that.creatOrder()
                            } else {
                                // 订单明细
                                that.isLoading = false;
                                that.confirms1()
                            }
                        }
                    });
                },
                creatOrder() {
                    var that = this
                    if (this.supplier.supplierId.length == 0 || this.supplier.supplierId == 0) {
                        this.$message({
                            message: '请选择供应商',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    // if (this.glimgList.length == 0 && this.listGlchioceImgData.length == 0) {
                    //     this.$message({
                    //         message: '请选择或者上传现场抓拍',
                    //         type: 'warning',
                    //         duration: 1000
                    //     });
                    //     return false
                    // }

                    if (this.fileList.length == 0) {
                        this.$message({
                            message: '请上传送货单照片',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    var dataJson = []
                    if (this.allTableData.length == 0) {
                        this.$message({
                            message: '请添加明细',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    for (var i = 0; i < this.allTableData.length; i++) {
                        dataJson.push({
                            purchaseOrderRecid: this.allTableData[i].recid,
                            purchaseOrderType: 1,
                            purchaseOrder: this.allTableData[i].orderNo,
                            buyPlanId: this.allTableData[i].buyPlanId,
                            purchaseMaterialDatas: this.allTableData[i].clmxList

                        })
                        if (dataJson.length == 0) {
                            this.$message({
                                message: '请添加明细',
                                type: 'warning',
                                duration: 1000
                            });
                            return false
                        }
                        for (var i = 0; i < dataJson.length; i++) {
                            for (var j = 0; j < dataJson[i].purchaseMaterialDatas.length; j++) {
                                // if (!dataJson[i].purchaseMaterialDatas[j].uuidlicensePlates) {
                                //     this.$message({
                                //         message: '请选择订单明细进场车牌',
                                //         type: 'warning',
                                //         duration: 1000
                                //     });
                                //     return false
                                // }
                                if (!dataJson[i].purchaseMaterialDatas[j].storageId || dataJson[i].purchaseMaterialDatas[j].storageId == 0) {
                                    this.$message({
                                        message: '请选择订单明细存放位置',
                                        type: 'warning',
                                        duration: 1000
                                    });
                                    return false
                                }
                            }
                        }
                    }
                    dataJson.push({
                        purchaseOrderRecid: '',
                        purchaseOrderType: 2,
                        purchaseOrder: '',
                        buyPlanId: '',
                        purchaseMaterialDatas: this.clmxList
                    })

                    for (var i = 0; i < this.clmxList.length; i++) {
                        // if (!this.clmxList[i].storageId || this.clmxList[i].storageId == 0) {
                        //     this.$message({
                        //         message: '无订单进场明细位置必须选择',
                        //         type: 'warning',
                        //         duration: 1000
                        //     });
                        //     return false
                        // }
                        if (this.clmxList[i].count == 0) {
                            this.$message({
                                message: '请输入无订单明细进场数量',
                                type: 'warning',
                                duration: 1000
                            });
                            return false
                        }
                        // if (!this.clmxList[i].uuidlicensePlates) {
                        //     this.$message({
                        //         message: '请选择无订单明细进场车牌',
                        //         type: 'warning',
                        //         duration: 1000
                        //     });
                        //     return false
                        // }
                    }
                    this.creatOrderList = JSON.parse(JSON.stringify(this.clmxList))
                    for (var i = 0; i < this.creatOrderList.length; i++) {
                        this.creatOrderList[i].price = 0
                        this.creatOrderList[i].taxRate = 0
                        this.creatOrderList[i].isedit = false
                        this.creatOrderList[i].manufacturerID = that.supplier.supplierId
                        this.creatOrderList[i].manufacturer = that.supplier.supplierName
                    }
                    this.noorderHtObj = {
                        noorderHtId: '',
                        noorderHtName: '',
                        suppilerId: '',
                        suppilerName: ''
                    }
                    this.orderdialogVisible = true
                },
                chioceht() {
                    var newArr = []
                    var that = this
                    for (var i = 0; i < this.creatOrderList.length; i++) {
                        newArr.push({
                            materialId: this.creatOrderList[i].materialId,
                            specificationId: this.creatOrderList[i].specsId,
                            materialName: this.creatOrderList[i].materialName,
                            specifiName: this.creatOrderList[i].specsName,
                            price: 0,
                            taxRate: 0,
                        })
                    }
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择合同',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        // area: ['50.1%', '64.25%'],
                        area: ['91.91%', '72.16%'],
                        content: '../publicList/cghtList.html?isSingle=1&isjccreatorder=1&creatClId=' + encodeURIComponent(JSON.stringify(newArr)) + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    for (var j = 0; j < that.creatOrderList.length; j++) {
                                        for (var i = 0; i < newList.list.length; i++) {
                                            if (newList.list[i].materialId == that.creatOrderList[j].materialId && newList.list[i].specsId == that.creatOrderList[j].specificationId) {
                                                var rows = that.creatOrderList[j]
                                                rows.price = newList.list[i].price
                                                rows.taxRate = newList.list[i].taxRate
                                                rows.isedit = true
                                                rows.manufacturerID = newList.info.suppilerId
                                                rows.manufacturer = newList.info.suppilerId
                                                that.$set(that.creatOrderList, j, rows)
                                            }
                                        }
                                    }
                                    that.noorderHtObj = {
                                        noorderHtId: newList.info.id,
                                        noorderHtName: newList.info.name,
                                        suppilerId: newList.info.suppilerId,
                                        suppilerName: newList.info.suppilerName
                                    }
                                    that.$forceUpdate()
                                }
                            }, 10)
                        }
                    });
                },
                confirms1(orderrecid, orderNo) {
                    if(this.isWddRequest){
                        return
                    }
                    var that = this
                    if (this.supplier.supplierId.length == 0 || this.supplier.supplierId == 0) {
                        this.$message({
                            message: '请选择供应商',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    // if (this.glimgList.length == 0 && this.listGlchioceImgData.length == 0) {
                    //     this.$message({
                    //         message: '请选择或者上传现场抓拍',
                    //         type: 'warning',
                    //         duration: 1000
                    //     });
                    //     return false
                    // }

                    if (this.fileList.length == 0) {
                        this.$message({
                            message: '请上传送货单照片',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    var dataJson = []
                    if (this.allTableData.length == 0) {
                        this.$message({
                            message: '请添加明细',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    for (var i = 0; i < this.allTableData.length; i++) {
                        dataJson.push({
                            purchaseOrderRecid: this.allTableData[i].recid,
                            purchaseOrderType: 1,
                            purchaseOrder: this.allTableData[i].orderNo,
                            buyPlanId: this.allTableData[i].buyPlanId,
                            purchaseMaterialDatas: this.allTableData[i].clmxList

                        })
                        if (dataJson.length == 0) {
                            this.$message({
                                message: '请添加明细',
                                type: 'warning',
                                duration: 1000
                            });
                            return false
                        }
                        for (var i = 0; i < dataJson.length; i++) {
                            if (dataJson[i].purchaseMaterialDatas.length > 0) {
                                for (var j = 0; j < dataJson[i].purchaseMaterialDatas.length; j++) {
                                    if (!dataJson[i].purchaseMaterialDatas[j].count || parseInt(dataJson[i].purchaseMaterialDatas[j].count) === 0) {
                                        this.$message({
                                            message: '请选择订单明细的进场数量',
                                            type: 'warning',
                                            duration: 1000
                                        });
                                        return false
                                    }
                                    // if (!dataJson[i].purchaseMaterialDatas[j].storageId || dataJson[i].purchaseMaterialDatas[j].storageId == 0) {
                                    //     this.$message({
                                    //         message: '请选择订单明细存放位置',
                                    //         type: 'warning',
                                    //         duration: 1000
                                    //     });
                                    //     return false
                                    // }
                                }
                            }
                        }
                    }
                    if (dataJson.length == 0) {
                        this.$message({
                            message: '请添加明细',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }


                    var pictureURL = []
                    var pictureId = []
                    var pictureUploadId = []
                    for (var i = 0; i < this.fileList.length; i++) {
                        pictureURL.push(this.fileList[i].fileid + ',' + this.fileList[i].filename + ',' + this.fileList[i].userName + ',' + this.fileList[i].uploadTime)
                    }
                    for (var i = 0; i < this.glimgList.length; i++) {
                        if (this.glimgList[i].types == 'upload') {
                            pictureUploadId.push(this.glimgList[i].fileid + ',' + this.glimgList[i].filename)
                        }
                        if (this.glimgList[i].types == 'glList') {
                            pictureId.push(this.glimgList[i].fileid)
                        }
                    }
                    for (var i = 0; i < this.listGlchioceImgData.length; i++) {
                        pictureId.push(this.listGlchioceImgData[i].fileid)
                    }
                    that.isWddRequest = true;
                    xLoading(true, '正在提交')
                    $.ajax({
                        type: 'post',
                        headers: {
                        },
                        url: baseUrl + '/Material/SaveApproachMatrtialData',
                        data: {
                            recordId: that.recordId,
                            recordNumber: that.recordNumber,
                            contractId: that.contract.contractId,
                            planId: that.plan.planId,
                            contractName: that.contract.contractName,
                            planName: that.plan.planName,
                            supplierName: that.supplier.supplierName,
                            supplierId: that.supplier.supplierId,
                            remarks: that.remarks,
                            isDetails: 1,
                            deliveryNotePic: pictureURL.join('|'),
                            approachCapturePic_Join: pictureId.join('|'),
                            approachCapturePic_Upload: pictureUploadId.join('|'),
                            dataJson: JSON.stringify(dataJson)
                        },
                        dataType: 'json',
                        success: function (res) {
                            xLoading(false)
                            if (!res.success) {
                                that.$message({
                                    message: res.msg ? res.msg : '程序错误，请重试',
                                    type: 'error'
                                });
                                that.isWddRequest = false;
                                return false;
                            }
                            that.$message({
                                message: '已提交',
                                type: 'success'
                            });
                            setTimeout(function () {
                                that.isWddRequest = false;
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            }, 500)
                        }
                    });
                },
                radioChange() {
                    this.contract = {
                        contractId: '',
                        contractName: ''
                    }
                    this.plan = {
                        planId: '',
                        planName: ''
                    }
                    this.supplier = {
                        supplierId: '',
                        supplierName: ''
                    }
                },
                prevewImg(urls) {
                    this.previewList = [urls];
                    setTimeout(function () {
                        var viewer = new Viewer(document.getElementById('jq22'), {
                            hide: function () {
                                viewer.destroy();
                            }
                        });
                        viewer.show();
                    }, 10);
                },
                downImg(filename, urls) {
                    publicdownFile(filename, urls)
                },
                removeImg(arr, index, types) {
                    var title = '此操作将永久删除该文件, 是否继续?'
                    if (types == 1) {
                        title = '此操作将永久删除该数据, 是否继续?'
                    }
                    this.$confirm(title, '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(function () {
                        arr.splice(index, 1)
                    }).catch(function () {
                    });
                },
                // 送货单上传
                shdhttprequest(file) {
                    this.uploadImg(file, 2)
                },
                // 抓拍上传
                zphttprequest(file) {
                    this.uploadImg(file, 1)
                },
                uploadImg(file, types) {
                    var that = this
                    if (getFileType(file.file.name) != 'IMG') {
                        this.$message({
                            message: '只能上传图片',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    xLoading(true, '正在上传')
                    var formData = new FormData();
                    formData.append('files', file.file);
                    $.ajax({
                        type: 'post',
                        url: baseUrl + '/Common/UploadFile?method=UploadFile&type=OSS',
                        data: formData,
                        dataType: 'json',
                        contentType: false,
                        processData: false,
                        success: function (res) {
                            xLoading(false)
                            if (!res.success) {
                                that.$message({
                                    message: res.msg,
                                    type: 'error'
                                });
                                return false;
                            }
                            var newobj = {
                                fileid: res.data.fileId,
                                filename: res.data.fileName,
                                fileurl: res.data.ossUrl,
                                uploadTime: res.data.uploadTime,
                                userName: res.data.userName,
                                types: 'upload'
                            }
                            if (types == 1) {
                                that.glimgList.push(newobj)
                            }
                            if (types == 2) {
                                that.fileList.push(newobj)
                            }
                        }
                    });
                },
                // 选择关联照片
                chioceGlimg() {
                    var that = this
                    var selectArr = []
                    for (var i = 0; i < this.glimgList.length; i++) {
                        if (this.glimgList[i].types == 'glList') {
                            selectArr.push({
                                id: this.glimgList[i].fileid
                            })
                        }
                    }
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '关联抓拍',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['55.62%', '68.61%'],
                        content: '../publicList/imgList.html?projectId=' + that.projectId + '&selectArr=' + encodeURIComponent(JSON.stringify(selectArr)) + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    for (var j = 0; j < that.glimgList.length; j++) {
                                        for (var i = 0; i < newList.length; i++) {
                                            if (newList[i].id == that.glimgList[j].id) {
                                                if (that.glimgList[j].types == 'glList') {
                                                    newList.splice(i, 1)
                                                }
                                            }
                                        }
                                    }
                                    for (var i = 0; i < newList.length; i++) {
                                        that.glimgList.push({
                                            fileid: newList[i].id,
                                            filename: '抓拍图片' + newList[i].id + '.png',
                                            fileurl: newList[i].url,
                                            types: 'glList'
                                        })
                                    }
                                }
                            }, 10)
                        }
                    });
                },
                // 选择采购合同
                chioceCght() {
                    var that = this
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择采购合同',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['60%', '77.77%'],
                        content: '../publicList/cghtList.html?isSingle=1&projectId=' + that.projectId + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    that.contract = {
                                        contractId: newList[0].id,
                                        contractName: newList[0].title
                                    }
                                    that.supplier = {
                                        supplierId: newList[0].suppilerId,
                                        supplierName: newList[0].suppilerName
                                    }
                                }
                            }, 10)
                        }
                    });
                },
                // 选择采购计划
                chioceCgjh() {
                    var that = this
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择采购计划',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['33.33%', '77.77%'],
                        content: '../publicList/cgjhList.html?isSingle=1&projectId=' + that.projectId + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    that.plan = {
                                        planId: newList[0].id,
                                        planName: newList[0].title
                                    }
                                }
                            }, 10)
                        }
                    });
                },
                // 选择供应商
                chioceGys() {
                    var that = this
                    if (that.supplier.supplierId.length > 0 && that.supplier.supplierId > 0) {
                        this.$confirm('是否更改供应商', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(function () {
                            parent.$('#publicValue').val('')
                            parent.layer.open({
                                type: 2,
                                title: '选择供应商',
                                shadeClose: true,
                                shade: 0.4,
                                skin: 'popup_layui',
                                area: ['60%', '77.77%'],
                                content: '../publicList/gysList.html?isSingle=1&companyId=' + that.companyId + '&' + new Date().getTime(),
                                end: function () {
                                    setTimeout(function () {
                                        if (parent.$('#publicValue').val()) {
                                            var newList = JSON.parse(parent.$('#publicValue').val())
                                            that.supplier = {
                                                supplierId: newList[0].id,
                                                supplierName: newList[0].name
                                            }

                                        }
                                    }, 10)
                                }
                            });
                        }).catch(function () {
                        });
                        return false
                    }
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择供应商',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['60%', '77.77%'],
                        content: '../publicList/gysList.html?isSingle=1&companyId=' + that.companyId + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    that.supplier = {
                                        supplierId: newList[0].id,
                                        supplierName: newList[0].name
                                    }
                                    that.allTableData = []
                                }
                            }, 10)
                        }
                    });
                },

                // 选择订单
                chioceorder() {
                    var that = this
                    if (that.supplier.supplierId.length == 0 || that.supplier.supplierId == 0) {
                        this.$message({
                            message: '请选择供应商',
                            type: 'warning',
                            duration: 1000
                        });
                        return false
                    }
                    var selectArr = []
                    for (var i = 0; i < this.allTableData.length; i++) {
                        selectArr.push({
                            recid: this.allTableData[i].recid,
                            orderNo: this.allTableData[i].orderNo
                        })
                    }
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择订单',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['91.91%', '72.16%'],
                        content: '../publicList/cgddList.html?supplierId=' + that.supplier.supplierId + '&projectId=' + that.projectId + '&selectArr=' + encodeURIComponent(JSON.stringify(selectArr)) + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    console.log(newList)
                                    var list = []
                                    for (var i = 0; i < newList.list.length; i++) {
                                        list.push({
                                            oper: 'add',
                                            isAdd: true,
                                            approachTime: timeFormat(new Date(), 1),
                                            materialId: newList.list[i].materialID,
                                            materialName: newList.list[i].materialName,
                                            specsId: newList.list[i].specificationId,
                                            specsName: newList.list[i].specificationName,
                                            unit: newList.list[i].unit,
                                            storageId: newList.list[i].warehouseId,
                                            storageName: newList.list[i].warehouseName,
                                            goodsShelvesId: newList.list[i].goodsShelvesId,
                                            goodsShelvesNumber: newList.list[i].goodsShelvesNumber,
                                            count: newList.list[i].approachQuantity,
                                            manufacturer: that.supplier.supplierName,
                                            manufacturerId: that.supplier.supplierId,
                                            uuidlicensePlates: '',
                                            showCpValue: ''
                                        })
                                    }
                                    that.allTableData.push({
                                        orderNo: newList.info.orderNo,
                                        recid: newList.info.recid,
                                        clmxList: list,
                                        isAdd: true,
                                        buyPlanId: newList.info.buyPlanId
                                    })
                                }
                            }, 10)
                        }
                    });
                },
                // 新增材料明细
                chioceClmx() {
                    var that = this
                    var selectArr = []
                    for (var i = 0; i < this.clmxList.length; i++) {
                        selectArr.push({
                            materialId: this.clmxList[i].materialId,
                            specificationId: this.clmxList[i].specsId
                        })
                    }
                    parent.$('#publicValue').val('')
                    parent.layer.open({
                        type: 2,
                        title: '选择材料明细',
                        shadeClose: true,
                        shade: 0.4,
                        skin: 'popup_layui',
                        area: ['52.08%', '64.81%'],
                        content: '../publicList/clmxList.html?projectId=' + that.projectId + '&selectArr=' + encodeURIComponent(JSON.stringify(selectArr)) + '&' + new Date().getTime(),
                        end: function () {
                            setTimeout(function () {
                                if (parent.$('#publicValue').val()) {
                                    var newList = JSON.parse(parent.$('#publicValue').val())
                                    for (var i = 0; i < newList.length; i++) {
                                        that.clmxList.push({
                                            oper: 'add',
                                            isAdd: true,
                                            materialId: newList[i].materialId,
                                            materialName: newList[i].materialName,
                                            specsId: newList[i].specificationId,
                                            specsName: newList[i].specificationName,
                                            unit: newList[i].unit,
                                            storageId: '',
                                            storageName: '',
                                            goodsShelvesNumber: '',
                                            count: 0,
                                            approachTime: timeFormat(new Date(), 1),
                                            uuidlicensePlates: '',
                                            showCpValue: ''
                                        })
                                    }
                                }
                            }, 10)
                        }
                    });
                },
                getDetailData() {
                    var that = this
                    xLoading(true)
                    $.ajax({
                        type: 'post',
                        headers: {
                        },
                        url: baseUrl + '/Material/GetAllApproachDatas',
                        data: {
                            id: that.recordId,
                            projectId: that.projectId
                        },
                        dataType: 'json',
                        success: function (res) {
                            xLoading(false)
                            if (!res.success) {
                                that.$message({
                                    message: res.msg ? res.msg : '程序错误，请重试',
                                    type: 'error'
                                });
                                return false;
                            }
                            that.approachCode = res.data.approachCode
                            that.recordNumber = res.data.approachCode
                            that.supplier = {
                                supplierId: res.data.supplierId,
                                supplierName: res.data.supplierName
                            }
                            that.remarks = res.data.remarks
                            var fileList = []
                            var glimgList = []
                            if (res.data.deliveryNotePic) {
                                for (var i = 0; i < res.data.deliveryNotePic.split('|').length; i++) {
                                    fileList.push({
                                        fileid: res.data.deliveryNotePic.split('|')[i].split(',')[0],
                                        filename: res.data.deliveryNotePic.split('|')[i].split(',')[1],
                                        fileurl: baseUrl + '/DataInput/FileService?method=DownloadFile&fileid=' + res.data.deliveryNotePic.split('|')[i].split(',')[0],
                                        uploadTime: res.data.deliveryNotePic.split('|')[i].split(',')[3],
                                        userName: res.data.deliveryNotePic.split('|')[i].split(',')[2]
                                    })
                                }
                            }
                            if (res.data.approachCapturePic_Upload) {
                                for (var i = 0; i < res.data.approachCapturePic_Upload.split('|').length; i++) {
                                    glimgList.push({
                                        fileid: res.data.approachCapturePic_Upload.split('|')[i].split(',')[0],
                                        filename: res.data.approachCapturePic_Upload.split('|')[i].split(',')[1],
                                        fileurl: baseUrl + '/DataInput/FileService?method=DownloadFile&fileid=' + res.data.approachCapturePic_Upload.split('|')[i].split(',')[0],
                                        types: 'upload'
                                    })
                                }
                            }
                            if (res.data.approachCapturePic_Join) {
                                for (var i = 0; i < res.data.approachCapturePic_Join.split('||').length; i++) {
                                    glimgList.push({
                                        fileid: res.data.approachCapturePic_Join.split('||')[i].split('|')[0],
                                        filename: '抓拍图片' + res.data.approachCapturePic_Join.split('||')[i].split('|')[0] + '.png',
                                        fileurl: res.data.approachCapturePic_Join.split('||')[i].split('|')[1],
                                        types: 'glList'
                                    })
                                }
                            }
                            that.fileList = fileList
                            that.glimgList = glimgList
                            that.allTableData = []
                            that.clmxList = []
                            for (var i = 0; i < res.data.purchaseOrderApproach.length; i++) {
                                for (var j = 0; j < res.data.purchaseOrderApproach[i].purchaseMaterialDatas.length; j++) {
                                    if (res.data.purchaseOrderApproach[i].purchaseMaterialDatas[j].uuidlicensePlates) {
                                        var arrs = res.data.purchaseOrderApproach[i].purchaseMaterialDatas[j].uuidlicensePlates.split('|')
                                        var newarr = []
                                        for (var k = 0; k < arrs.length; k++) {
                                            newarr.push(arrs[k].split(',')[1])
                                        }
                                        res.data.purchaseOrderApproach[i].purchaseMaterialDatas[j].showCpValue = newarr.join(',')
                                    }
                                }
                                if (res.data.purchaseOrderApproach[i].purchaseOrderType == 1) {
                                    that.allTableData.push({
                                        orderNo: res.data.purchaseOrderApproach[i].purchaseOrder,
                                        recid: res.data.purchaseOrderApproach[i].purchaseOrderRecid,
                                        buyPlanId: res.data.purchaseOrderApproach[i].buyPlanId,
                                        clmxList: res.data.purchaseOrderApproach[i].purchaseMaterialDatas
                                    })
                                }
                                if (res.data.purchaseOrderApproach[i].purchaseOrderType == 2) {
                                    that.clmxList = res.data.purchaseOrderApproach[i].purchaseMaterialDatas
                                }
                            }

                        }
                    });
                }
            },
            mounted() {
                var that = this
                this.showApp = true;
                this.recordId = getQuerys('recordId')
                this.projectId = getQuerys('projectId')
                this.companyId = getQuerys('companyId')
                this.getDetailData()
            }
        });
    </script>
</body>
<style>
    .page-container {
        padding-bottom: 80px;
        position: relative;
    }

    .but_box {
        position: absolute;
        left: 0;
        bottom: 0;
    }

    .top_box {
        overflow: hidden;
        width: 100%;
        padding: 0 3.34vw;
        padding-top: 1.56vh;
    }

    .contetn_box {
        width: 100%;
        height: 100%;
        overflow: auto;
    }

    .cell_box {
        float: left;
        padding-bottom: 20px;
    }

    .cell_title {
        display: flex;
        align-items: center;
        padding: 10px 0;
        height: 52px;
    }

    .cell_but {
        padding-left: 10px;
    }

    .cell_cont {
        overflow: auto;
        padding: 2.77vh 2.08vw;
        border: 1px solid #EBEBEB;
    }

    .form_box {
        display: flex;
        width: 100%;
        margin-top: 20px;
    }

    .form_name {
        line-height: 32px;
        width: 94px;
        min-width: 94px;
        padding-right: 10px;
        text-align: right;
    }

    .form_cont {
        display: flex;
        align-items: center;
        line-height: 1;
        flex: 1;
        flex-wrap: wrap;
    }

    .el-radio {
        margin-right: 2.51vw;
        line-height: 32px;
    }

    .el-input.is-disabled .el-input__inner {
        background: #FAFBFC;
        color: #333333;
        border: 1px solid #BBBBC5;
    }

    .el-textarea__inner {
        background: #FAFBFC;
        border: 1px solid #BBBBC5;
    }

    .file_item {
        margin-left: 20px;
        margin-top: 20px;
        width: 140px;
        height: 140px;
        overflow: hidden;
        border-radius: 5px;
        float: left;
        position: relative;
    }

    .el-upload--picture-card {
        width: 100%;
        height: 100%;
        border-color: #D6D6D6;
        background: #FAFBFC;
    }

    .file_item>div {
        width: 100%;
        height: 100%;
    }

    .file_mask {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.5s;
    }

    .file_mask>div {
        font-size: 22px;
        color: #fff;
        cursor: pointer;
    }

    .file_item:hover .file_mask {
        opacity: 1;
    }

    .txt_link>span {
        text-decoration: underline;
    }

    .public_popup_box {
        height: 100%;
    }

    .public_popup_cell_box {
        padding: 2.77vh 2.08vw 0;
        height: calc(100% - 70px);
        overflow: auto;
    }

    .public_popup {
        height: 70vh;
        margin-top: 15vh !important;
    }

    .popup_cell_item {
        margin-bottom: 20px;
    }

    .popup_cell_name {
        width: 122px;
        padding-right: 10px;
        text-align: right;
        line-height: 32px;
    }

    .popup_cell_cont {
        padding-right: 100px;
        display: flex;
        align-items: center;
        flex: 1;
    }

    .creat_order_box {
        display: flex;
        align-items: center;
    }

    .creat_order_table {
        height: calc(100% - 32px);
        padding-top: 10px;
        padding-bottom: 10px;
    }
</style>

</html>